<?php

/**
 * @author krku
 */
function smarty_function_formError($params, &$smarty) {

	$errorList = $smarty->get_template_vars('errorList');

	if (!isset($params['errorClass'])) {
		$params['errorClass'] = "warning";
	}

	$err = '';

	if (sizeof($errorList)) {
		foreach ($errorList as $k => $v) {
			if ($v['field'] == $params['name']) {
				$err .= $v['msg'];
			}
		}
	}

	$ret = '';

	if ($err) {
		$ret .= '<p ' . (isset($params['errorClass']) ? 'class="' . $params['errorClass'] . '" ' : '') . 'id="' . $params['name'] . 'Error">';
		$ret .= $err . '</p>';
	}

	return $ret;
}

?>
